{include file="public/header"}
{load href="/public/static/Content/ThemesBusiness/ListPage.css"}
<style>
    .datagrid-view {
        overflow-x: scroll;
    }
</style>
<script src="/public/static/Scripts/common-binder-list-view.js"></script>
<script src="/public/static/Scripts/ScriptsEasyui/datagrid-filter.js"></script>

<script type="text/javascript">

    var data = null;
    var gridListHandler = new listGridHandler(data, 'gridListHandler', 'gridList');
    gridListHandler.formName = '标签下载';
    gridListHandler.enableFilter = false;
    $(function () {
        gridListHandler.bindFilter($('#gridList'));
    });
    gridListHandler.getNewUrl = function (id) {
        return '/admin/goodstags/add';
    };
    /* gridListHandler.getEditUrl = function(recordID) {
         return '/admin/usergroup/edit/' + recordID;
     };*/

    gridListHandler.getDeleteUrl = function (recordID) {
        return '/admin/goodstags/del/' + recordID;

    };
    function formatState(val, row, index) {
        if (row.status == 0) {
            val = '<span style="display:inline-block;background-color:#abbac3;color:#fff;padding:1px 5px;">' +
                '正常' +
                '</span>';
        }
        else {
            val = '<span style="display:inline-block;background-color:#d15b47;color:#fff;padding:1px 5px;">' +
                '停用' +
                '</span>';
        }
        return val;
    }

    function Search() {
        var str = "";
        // if($("#GroupID").combo('getValue')!=0){
        //     str+="GroupID="+$("#GroupID").combo('getValue')+"&";
        // }
        if ($("#Search").val() != "") {
            str += $("#Search").val();
        }

        $('#gridList').datagrid('load', {
            tj: $("#GroupID").combo('getValue'),
            search: $("#Search").val(),
        });
    }

    function daochu() {
        var stime = $('#stime').datebox('getValue');
        var etime = $('#etime').datebox('getValue');
        if (stime != "" && etime == "") {
            $.messager.alert('提示', '请先输入结束时间', 'error');
            return false;
        }
        if (etime != '' && stime == '') {
            $.messager.alert('提示', '请先输入起始时间', 'error');
            return false;
        }

        location.href = "daochu.html?stime=" + stime + "&etime=" + etime;
    }

    function EditRecord(id) {
        //alert(id);return;
        if (id <= 0) {
            $.messager.alert('提示', "没有ID", 'info');
            return 0;
        } else {
            window.showBusinessForm("编辑", '/admin/goodstags/edit.html?id=' + id);
        }


    }

    function importsn(id) {
        window.showBusinessForm("序列号导入", '/admin/goodstags/import_sn.html?id=' + id);
    }

    function del(id) {
        if (id <= 0) {
            $.messager.alert('提示', "删除失败", 'info');
            return 0;
        }

        $.messager.confirm('删除确认', '确实要删除选中的记录？', function (r) {
            if (r) {
                $.ajax({
                    type: "POST",
                    url: 'del.html?id=' + id,
                })
                    .success(function (result) {
                        if (result.status > 0) {
                            $.messager.alert('提示', result.msg, "info");
                            window.location.reload();
                        } else {
                            $.messager.alert('提示', result.msg, "error");
                        }
                    })
                    .error(function (result) {
                        var message = "很抱歉，操作出现异常！请联系管理员。";
                        if (result) {
                            if (result.responseJSON && result.responseJSON.ExceptionMessage) {
                                message = result.responseJSON.ExceptionMessage;
                            }
                            else if (result.responseText) {
                                message = result.responseText;
                            }
                        }

                        $.messager.alert('错误', message.replace("-10", ""), 'error');
                    });
            }
        });

    }

    function formatAction(val, row, index) {

        val = '{eq name="power.downloadlabel" value="true"}<a href="/uploads/tags/' + row.id + '/' + row.tags_name + '.zip" title="下载防伪标签">下载防伪标签</a>{/eq}';
        val += '{eq name="power.snimport" value="true"} | <a href="javascript:;" onclick="importsn(' + row.id + ')" title="防伪标签序列号导入">序列号导入</a>{/eq}';
        return val;
    }

    //商标生成数量1-1
    function countAction(val, row, index) {

        val = '<a href="#" onclick="show_count(' + row.id + ')" title="商品数量" style="color:#1024EE;"> ' + row.count + '</a>';
        return val;
    }

    //商标生成数量1-2
    show_count = function (id) {
        //alert(id);
        //window.parent.window.MenuClickHrefEvent('/admin/proview/good_list?tag_id='+id, '商品列表', 'tabsChildContent_0', false);
        window.showBusinessForm("商品列表", '/admin/proview/good_list?tag_id=' + id);
    };

</script>


<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north',border:false" class="grid-toolbar-panel" id="gridList_ToolBar">
        <a href="#" id="news" class="easyui-linkbutton grid-toolbar-button"></a>
        <!-- <a href="#" id="news" onclick="gridListHandler.showNewDialog()" class="easyui-linkbutton grid-toolbar-button"
            data-options="iconCls:'icon-add'" title="新建">新建</a> -->
        <span style="padding-left:50px;">按条件查询：
            <select class="easyui-combobox" name="state" id="GroupID" data-options="required:true,tipPosition:'right',"
                style="width:152px;">
                <option value="0">按商品名称</option>
                <option value='1'>按标签生成数量</option>
            </select>
            <input type="text" id="Search" />
            <a href="#" style="padding-left:10px;" onclick="Search()">查询</a>
            &nbsp;&nbsp;
            起始时间：<input id="stime" type="text" class="easyui-datebox" style="width:100px;" value="">-
            结束时间：<input id="etime" type="text" class="easyui-datebox" style="width:100px;" value="">
            {eq name="power.export" value="true"}
            <a href="#" style="padding-left:10px;" onclick="daochu()">导出数据</a>
            {/eq}
        </span>
    </div>
    <div data-options="region:'center',border:false">
        <table id="gridList" exusagetype="MultiSelection"
            data-options="pagination:true,pageSize:15,pageList:[10,15,20],multiSort:true,remoteSort:true,striped:true,fit:true,fitColumns:true,rownumbers:true,idField:'_ID',singleSelect: true"
            url="/admin/goodstags/index.html?ajax=1">
            <thead data-options="frozen:true">
                <tr>
                    <th data-options="field:'id',width:200,halign:'center',align:'center',formatter:formatAction">操作
                    </th>
                    <th data-options="field:'name',halign:'center',align:'left',width:200"><span
                            class="grid-header-sortable">商品名称</span></th>
                    <!-- <th data-options="field:'jxs',halign:'center',align:'left',width:150"><span
                            class="grid-header-sortable">经销商</span></th>
                    <th data-options="field:'number',halign:'center',align:'left',width:150"><span
                            class="grid-header-sortable">验证次数</span></th>
                    <th data-options="field:'type_name',halign:'center',align:'left',width:150"><span
                            class="grid-header-sortable">条码类型</span></th> -->
                    <th data-options="field:'count',halign:'center',align:'left',width:150,formatter:countAction"><span
                            class="grid-header-sortable">标签生成数量</span></th>
                    <th data-options="field:'sn_count',halign:'center',align:'left',width:150"><span
                            class="grid-header-sortable">未导入序列号数量</span></th>
                    <!-- <th data-options="field:'active_status',halign:'center',align:'left',width:150"><span
                            class="grid-header-sortable">状态</span></th> -->
                    <th data-options="field:'addtime',halign:'center',align:'left',width:150"><span
                            class="grid-header-sortable">添加时间</span></th>
                </tr>
            </thead>

        </table>


    </div>
</div>
{include file="public/footer"/}